home *** CD-ROM | disk | FTP | other *** search
/ SunSoft Catalyst CDWARE 1996 May to August / Catalyst CDWARE 1996 May to August.iso / .products / .bin / httpd / Solaris_2 / initdev.pl < prev    next >
Perl Script  |  1996-02-27  |  4KB  |  123 lines

  1. #!./perl
  2.  
  3. # ------------------------------------------------------------
  4.  
  5. # initdev.pl, by Jean-Pierre Girard (jpg@corrado.sun.com)
  6. # This allows the development environment to choose what
  7. # page to load depending on the existence of .cdev
  8.  
  9. # ------------------------------------------------------------
  10.  
  11. # Bugs and other fixes
  12.  
  13. # ------------------------------------------------------------
  14.  
  15. $BASEDIR = $ENV{"DOCUMENT_ROOT"};
  16. require 'devinfo.pl';
  17. require 'tools.pl';
  18. $ShortDir = &GetDevinfo("dir");
  19. $ShortDir =~ s?.*/([^/]*)$?\1?;
  20.  
  21. if ($ENV{'REQUEST_METHOD'} eq "POST") {
  22.     read(STDIN, $request, $ENV{'CONTENT_LENGTH'});
  23. } elsif ($ENV{'REQUEST_METHOD'} eq "GET" ) {
  24.     $request = $ENV{'QUERY_STRING'};
  25. }
  26. $request =~ s/%(..)/pack("c",hex($1))/ge;
  27.  
  28. if (@ARGV == 0 && $request eq "") {
  29.     if ($ShortDir eq "") {
  30.         $HasDir = 0;
  31.     } else {
  32.         $HasDir = 1;
  33.         $CompDir = "$BASEDIR/$ShortDir";
  34.     }
  35. } elsif ($request eq "DISPLAY") {
  36.     $HasDir = 0;
  37. } else {
  38.     $HasDir = 1;
  39.     
  40.     $DirCompName = ($request eq ""? $ARGV[0]: $request);
  41.     $DirCompName =~ s/^Menu_dir=//;
  42.     $DirCompName =~ s/^IsIndex=//;
  43.     $DirCompName =~ s/[     \n]*$//;
  44.     substr($DirCompName, 0, 1) =~ tr/a-z/A-Z/;
  45.     $DirCompName =~ tr/a-zA-Z0-9./_/c;
  46.     $CompDir=$BASEDIR . "/" . $DirCompName;
  47.     if ( -d $CompDir ) {
  48.         unless ( -w $CompDir) {
  49.             $HasDir = 0;
  50.             $Err = 1;
  51.         }
  52.     } else {
  53.         unless (mkdir($CompDir, 0777)) {
  54.             $HasDir = 0;
  55.             $Err = 2;
  56.         }
  57.     }
  58. }
  59.  
  60. if ($HasDir == 0) {
  61.     $ListDir = `ls $BASEDIR`;
  62.     $ListDir =~ s/hotjava\n|CDware\n|tmp\n|DEV\n|([^     \n]*\.Z)//g;
  63.     $ListDir =~ s/(.*)\n+/<OPTION>\1\n/g;
  64.     write;
  65. } else {
  66.     &PrintDevinfo($CompDir, 0);
  67.     $URL="file://" . $BASEDIR . "/DEV/index.html";
  68.     $URL="http://localhost:7999/cgi-bin/mainmenu.pl?";
  69.     print "Location:  $URL\n\n";
  70.     #print "Content-type: text/html\n\n\n<html><body>URL=$URL<br>";
  71.     #print "dir=$CompDir<br>";
  72.     #print "dir devinfo=", &GetDevinfo("dir"), "<br>";
  73.     #print "status devinfo=", &GetDevinfo("status");
  74.     #print "\n</body></html>";
  75. }
  76.  
  77. format STDOUT =
  78. Content-type: text/html
  79.  
  80.  
  81. <html>
  82. <title>Welcome to the Developer's Kit</title>
  83.  
  84. <body>
  85. <center><IMG src="file:///tmp/httpd/.products/CDware/images/startup.gif"></center>
  86. @*
  87. ($Err == 1 ? "<H3><dd><app class=\"ImageLoopItem\" img=\"file:///tmp/httpd/.products/DEV/images/blinkingAlert\" ALIGN=middle pause=0 width=56 height=49 pause = 200>Not a writable directory. Change user or rights.</H3></dd>\n": "")
  88. @*
  89. ($Err == 2 ? "<H3><dd><app class=\"ImageLoopItem\" img=\"file:///tmp/httpd/.products/DEV/images/blinkingAlert\" ALIGN=middle pause=0 width=56 height=49 pause = 200>Cannot create the directory. Change user or rights of the .products directory.</H3></dd>\n": "")
  90. <center>
  91. <app class="DancingText" font=TimesRoman30b text="Welcome to the CDware Developer's Kit" time=2000 pause=1500></center>
  92. #<H1>Welcome to the CDware Developer's Kit</H1></center>
  93. <b><p>This kit will help you develop your insertion to the Catalyst program.</br>
  94. It uses HotJava, the web browser developped by SunSoft around Java, to guide you through the different steps of the creation.</p></b>
  95. <p><IMG ALIGN=middle SRC="file:///tmp/httpd/.products/DEV/images/finger.gif">
  96. The first time you 're starting this Kit, you need to provide a directory name.
  97. <p>This directory will be created in the <b>"@*
  98. $BASEDIR
  99. "</b> directory if it doesn't already exist. Make sure you have write permissions in this directory. This name should resemble your company name, and all the files of your submission will have to be under this directory.
  100. <br><p>Directory name:
  101. <FORM method="post"  ACTION="http://localhost:7999/cgi-bin/initdev.pl">
  102. <INPUT TYPE="text" 
  103. ~@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  104. $Dir
  105.  NAME="IsIndex" SIZE="35" MAXLENGTH=50
  106. value="@*
  107. $ShortDir
  108. "><input type="submit" VALUE="Ok" >
  109. #<input type="Reset" VALUE="Reset" >
  110. </FORM>
  111. <hr>
  112. <h4>Existing company directories: </h4>
  113. <form method="post"  ACTION="http://localhost:7999/cgi-bin/initdev.pl">
  114. <center><SELECT name="Menu_dir" size="10">
  115. @*
  116. $ListDir
  117. </SELECT>
  118. <input type="submit" VALUE="Ok" >
  119. #<input type="Reset" VALUE="Reset" >
  120. </center></form>
  121. </body></html>
  122. .
  123.